﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace RadioPlayer
{
	public partial class RadioManagement : Form
	{
		private RadioHelper m_listeRadios;

		public RadioManagement()
		{
			InitializeComponent();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			this.Close();
		}

		private void RadioManagement_Load(object sender, EventArgs e)
		{
			//désérialization de la liste pour tout mettre dedans
			m_listeRadios = new RadioHelper();
			List<RadioObject> liste = m_listeRadios.Liste;
			foreach (RadioObject radio in liste)
			{
				radioObjectBindingSource.Add(radio);
			}
		}

		private void RadioManagement_FormClosing(object sender, FormClosedEventArgs e)
		{
			if (m_listeRadios.Count != radioObjectBindingSource.List.Count)
			{
				foreach (RadioObject radio in radioObjectBindingSource.List)
				{
					m_listeRadios.AddRadio(radio);
				}
			}
			m_listeRadios.Serialize();
		}
	}
}
